{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<script type=\"text/javascript\">window.PlotlyConfig = {MathJaxConfig: 'local'};</script><script type=\"text/javascript\">if (window.MathJax) {MathJax.Hub.Config({SVG: {font: \"STIX-Web\"}});}</script><script>requirejs.config({paths: { 'plotly': ['https://cdn.plot.ly/plotly-latest.min']},});if(!window._Plotly) {require(['plotly'],function(plotly) {window._Plotly=plotly;});}</script>"
      ],
      "text/vnd.plotly.v1+html": [
       "<script type=\"text/javascript\">window.PlotlyConfig = {MathJaxConfig: 'local'};</script><script type=\"text/javascript\">if (window.MathJax) {MathJax.Hub.Config({SVG: {font: \"STIX-Web\"}});}</script><script>requirejs.config({paths: { 'plotly': ['https://cdn.plot.ly/plotly-latest.min']},});if(!window._Plotly) {require(['plotly'],function(plotly) {window._Plotly=plotly;});}</script>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# https://plot.ly/python/anova/\n",
    "\n",
    "import plotly as py\n",
    "import plotly.graph_objs as go\n",
    "import plotly.figure_factory as ff\n",
    "\n",
    "import numpy as np\n",
    "import pandas as pd\n",
    "import scipy\n",
    "\n",
    "import statsmodels\n",
    "import statsmodels.api as sm\n",
    "from statsmodels.formula.api import ols\n",
    "\n",
    "import warnings\n",
    "warnings.filterwarnings(\"ignore\", message=\"numpy.dtype size changed\")\n",
    "warnings.filterwarnings(\"ignore\", message=\"numpy.ufunc size changed\")\n",
    "\n",
    "py.offline.init_notebook_mode(connected=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "+-------+-----------------+\n",
      "| Moore | R Documentation |\n",
      "+-------+-----------------+\n",
      "\n",
      "Status, Authoritarianism, and Conformity\n",
      "----------------------------------------\n",
      "\n",
      "Description\n",
      "~~~~~~~~~~~\n",
      "\n",
      "The ``Moore`` data frame has 45 rows and 4 columns. The data are for\n",
      "subjects in a social-psychological experiment, who were faced with\n",
      "manipulated disagreement from a partner of either of low or high status.\n",
      "The subjects could either conform to the partner's judgment or stick\n",
      "with their own judgment.\n",
      "\n",
      "Usage\n",
      "~~~~~\n",
      "\n",
      "::\n",
      "\n",
      "   Moore\n",
      "\n",
      "Format\n",
      "~~~~~~\n",
      "\n",
      "This data frame contains the following columns:\n",
      "\n",
      "partner.status\n",
      "   Partner's status. A factor with levels: ``high``, ``low``.\n",
      "\n",
      "conformity\n",
      "   Number of conforming responses in 40 critical trials.\n",
      "\n",
      "fcategory\n",
      "   F-Scale Categorized. A factor with levels (note levels out of order):\n",
      "   ``high``, ``low``, ``medium``.\n",
      "\n",
      "fscore\n",
      "   Authoritarianism: F-Scale score.\n",
      "\n",
      "Source\n",
      "~~~~~~\n",
      "\n",
      "Moore, J. C., Jr. and Krupat, E. (1971) Relationship between source\n",
      "status, authoritarianism and conformity in a social setting.\n",
      "*Sociometry* **34**, 122–134.\n",
      "\n",
      "Personal communication from J. Moore, Department of Sociology, York\n",
      "University.\n",
      "\n",
      "References\n",
      "~~~~~~~~~~\n",
      "\n",
      "Fox, J. (2008) *Applied Regression Analysis and Generalized Linear\n",
      "Models*, Second Edition. Sage.\n",
      "\n",
      "Fox, J. and Weisberg, S. (2011) *An R Companion to Applied Regression*,\n",
      "Second Edition, Sage.\n",
      "\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>partner_status</th>\n",
       "      <th>conformity</th>\n",
       "      <th>fcategory</th>\n",
       "      <th>fscore</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>low</td>\n",
       "      <td>8</td>\n",
       "      <td>low</td>\n",
       "      <td>37</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>low</td>\n",
       "      <td>4</td>\n",
       "      <td>high</td>\n",
       "      <td>57</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>low</td>\n",
       "      <td>8</td>\n",
       "      <td>high</td>\n",
       "      <td>65</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>low</td>\n",
       "      <td>7</td>\n",
       "      <td>low</td>\n",
       "      <td>20</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>low</td>\n",
       "      <td>10</td>\n",
       "      <td>low</td>\n",
       "      <td>36</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>low</td>\n",
       "      <td>6</td>\n",
       "      <td>low</td>\n",
       "      <td>18</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>low</td>\n",
       "      <td>12</td>\n",
       "      <td>medium</td>\n",
       "      <td>51</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>low</td>\n",
       "      <td>4</td>\n",
       "      <td>medium</td>\n",
       "      <td>44</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>low</td>\n",
       "      <td>13</td>\n",
       "      <td>low</td>\n",
       "      <td>31</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>low</td>\n",
       "      <td>12</td>\n",
       "      <td>low</td>\n",
       "      <td>36</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  partner_status  conformity fcategory  fscore\n",
       "0            low           8       low      37\n",
       "1            low           4      high      57\n",
       "2            low           8      high      65\n",
       "3            low           7       low      20\n",
       "4            low          10       low      36\n",
       "5            low           6       low      18\n",
       "6            low          12    medium      51\n",
       "7            low           4    medium      44\n",
       "8            low          13       low      31\n",
       "9            low          12       low      36"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 拉取数据\n",
    "moore_dataset = sm.datasets.get_rdataset(\"Moore\", \"carData\", cache=True)\n",
    "print(moore_dataset.__doc__)\n",
    "moore_df = moore_dataset.data\n",
    "moore_df.rename(columns={\"partner.status\":\"partner_status\"}, inplace=True)\n",
    "moore_df.head(n=10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "hhelo\n"
     ]
    }
   ],
   "source": [
    "print(\"hhelo\")\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'aa': 'bb'}\n"
     ]
    }
   ],
   "source": [
    "dirs = {\"aa\": \"bb\"}\n",
    "\n",
    "print(dirs)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.4.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
